
#pragma once

#include <cstdint>
#include <string>
#include <memory>
#include <cstring>
#include <unistd.h>
#include "data_buffer.h"
#include "define.h"

class LoopEvent;

class Channel : public std::enable_shared_from_this<Channel>
{
public:
    Channel();
    Channel(LoopEvent * loop, int socket, WriteAbleCallback && w_func, ReadAbleCallback && r_func, ErrorCallback && e_func);
public:
    void EventCallback(int event_type);
    void AddEvent(int event_type);
    void UpdateEvent(int event_type);
    int GetSocketFd()   {   return m_socket_fd; }
    int64_t GetChannelId() { return m_channel_id;}
    void RemoveEvent();
private:
    LoopEvent * m_loop_event;    
private:
    WriteAbleCallback m_write_cb;
    ReadAbleCallback  m_read_cb;
    ErrorCallback     m_error_cb;
private:
    int m_event_type;
    int m_socket_fd;
    int64_t m_channel_id;
};